package com.oamicnet.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {
    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // 方法调用前增强
        System.out.println("方法调用前，参数：" + args[0]);
        // 调用原方法
        Object result = method.invoke(target, args);
        // 方法调用后增强
        System.out.println("方法调用后");
        return result;
    }
}
